﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FPSO.Models.Domain
{
    public class ShipCalcState
    {
        /// <summary>
        /// 排水量
        /// </summary>
        public double Disp { get; set; }
        /// <summary>
        /// 货油舱总重量
        /// </summary>
        public double Cargow { get; set; }
        /// <summary>
        /// 压载舱总重量
        /// </summary>
        public double Ballastw { get; set; }
        /// <summary>
        /// 横稳心高
        /// </summary>
        public double KMT { get; set; }
        /// <summary>
        /// 重心X
        /// </summary>
        public double LCG { get; set; }
        /// <summary>
        /// 重心Z
        /// </summary>
        public double VCG { get; set; }
        /// <summary>
        /// 初稳心高
        /// </summary>
        public double GM { get; set; }
        /// <summary>
        /// 舯吃水
        /// </summary>
        public double TM { get; set; }
        /// <summary>
        /// 横倾
        /// </summary>
        public double Heel { get; set; }
        /// <summary>
        /// 纵倾
        /// </summary>
        public double Trim { get; set; }
        /// <summary>
        /// 最大剪力百分比
        /// </summary>
        public double MaxPersf { get; set; }
        /// <summary>
        /// 最大弯矩百分比
        /// </summary>
        public double MaxPerbm { get; set; }

        public ShipCalcState()
        {
            Disp = 0d;
            Cargow = 0d;
            Ballastw = 0d;
            KMT = 0d;
            LCG = 0d;
            VCG = 0d;
            GM = 0d;
            TM = 0d;
            Heel = 0d;
            Trim = 0d;
            MaxPersf = 0d;
            MaxPerbm = 0d;
        }

		private double weight_check_limit = 5.0;
		private double length_check_limit = 0.01;
		public bool isEqual(ShipCalcState newShipStatus)
		{
			bool check = true;
			if (Math.Abs(Disp - newShipStatus.Disp) > weight_check_limit
				|| Math.Abs(Ballastw - newShipStatus.Ballastw) > weight_check_limit
				|| Math.Abs(Cargow - newShipStatus.Cargow) > weight_check_limit)
				check = false;
			else if (Math.Abs(LCG - newShipStatus.LCG) > length_check_limit
				|| Math.Abs(TM - newShipStatus.TM) > length_check_limit
				|| Math.Abs(GM - newShipStatus.GM) > length_check_limit)
				check = false;
			return check;
		}
	
	}
}
